package com.mnsq.book.controller;

import com.mnsq.book.service.BookService;
import com.mnsq.common.bean.annotation.UserInfoRequired;
import com.mnsq.common.bean.entity.book.Book;
import com.mnsq.common.bean.vo.book.BookCondition;
import com.mnsq.common.controller.BaseController;
import com.mnsq.common.service.BaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import matrix.module.common.bean.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 * @date 2019/1/22 0022
 */
@Api("书籍类接口")
@RestController
@RequestMapping(value = "/api/book")
public class BookController extends BaseController<Book, BaseService<Book, BookCondition>, BookCondition> {

    @Autowired
    private BookService bookService;

    @ApiOperation(value = "分页条件查询书籍信息", notes = "分页查询")
    @PostMapping("/page/query")
    public Result queryPageList(@RequestBody BookCondition bookCondition) {
        return Result.success(bookService.queryPageByCondition(bookCondition));
    }

    @ApiOperation(value = "分类topFive查询", notes = "topFive")
    @PostMapping("/top/five")
    public Result topFive(@RequestBody BookCondition bookCondition) {
        return Result.success(bookService.topFive(bookCondition));
    }

    @ApiOperation(value = "guessUserLike，猜你喜欢", notes = "guessUserLike")
    @UserInfoRequired(required = true)
    @PostMapping("/guess/user/like")
    public Result guessUserLike(@RequestBody BookCondition bookCondition) {
        return bookService.guessUserLike();
    }

    @ApiOperation(value = "userReadPage，已读列表，分页", notes = "userReadPage")
    @UserInfoRequired(required = true)
    @PostMapping("/user/read/page")
    public Result userReadPage(@RequestBody BookCondition baseCondition) {
        return bookService.userReadPage(baseCondition);
    }

    @ApiOperation(value = "book information，详细内容", notes = "detail info")
    @PostMapping("/info/detail")
    public Result bookInfoDetail(@RequestBody BookCondition bookCondition) {
        // TODO 书籍详细信息，包括但不限于文字数量，重量，主色调，等等信息
        return null;
    }

    @ApiOperation(value = "已读详情查询", notes = "userReadDetail")
    @UserInfoRequired(required = true)
    @PostMapping("/user/read/detail")
    public Result userReadDetail(@RequestBody BookCondition bookCondition) {
        return bookService.userReadDetail(bookCondition);
    }

    @ApiOperation(value = "加入/取消 书单", notes = "加入书单")
    @UserInfoRequired(required = true)
    @PostMapping("/add/book/list")
    public Result addBookList(@RequestBody BookCondition bookCondition) {
        return bookService.addBookList(bookCondition);
    }

    @ApiOperation(value = "分页书单列表", notes = "分页书单列表")
    @UserInfoRequired(required = true)
    @PostMapping("/book/list/page")
    public Result bookListPage(@RequestBody BookCondition bookCondition) {
        return bookService.addBookListPage(bookCondition);
    }

    @ApiOperation(value = "已读书籍，评分与评论", notes = "comment")
    @UserInfoRequired(required = true)
    @PostMapping("/read")
    public Result readBook(@RequestBody BookCondition bookCondition) {
        return bookService.read(bookCondition);
    }
}
